package operation.madiator.obj;

import operation.madiator.abs.Colleague;
import operation.madiator.abs.Mediator;

public class Alarm extends Colleague {

    // 创建一个同事对象的同时，将同事对象注册到中介者中
    public Alarm(Mediator mediator, String name) {
        super(mediator, name);
        mediator.register(name, this);
    }

    public void sendAlarm(int stateChange) {
        sendMessage(stateChange);
    }

    @Override
    protected void sendMessage(int stateChange) {
        this.getMediator()
                .getMessage(stateChange, this.getName());
    }
}
